import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:raze/potions/raze_constant.dart';
import 'package:raze/potions/spatial_alchemy.dart';

/// 登录提示弹窗组件
class AuthPortalDialog {
  /// 显示登录提示弹窗
  static void revealAuthPortal() {
    Get.dialog(const _AuthPortalWidget(), barrierDismissible: true);
  }
}

/// 登录提示弹窗内部组件
class _AuthPortalWidget extends StatelessWidget {
  const _AuthPortalWidget();

  @override
  Widget build(BuildContext context) {
    return Dialog(
      backgroundColor: Colors.transparent,
      elevation: 0,
      child: Container(
        width: 320.w,
        decoration: BoxDecoration(
          color: RazeConstants.white,
          borderRadius: BorderRadius.circular(20.r),
          border: Border.all(
            color: RazeConstants.blue.withOpacity(0.3),
            width: 2,
          ),
          boxShadow: [
            BoxShadow(
              color: RazeConstants.black.withOpacity(0.15),
              blurRadius: 20,
              offset: const Offset(0, 8),
            ),
          ],
        ),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            // Logo装饰区域
            24.h.boxHeight,
            Container(
              width: 70.w,
              height: 70.w,
              decoration: BoxDecoration(
                color: RazeConstants.yellow.withOpacity(0.2),
                shape: BoxShape.circle,
                border: Border.all(
                  color: RazeConstants.blue.withOpacity(0.3),
                  width: 2,
                ),
              ),
              child: Image.asset(
                'assets/images/small-logo.png',
                width: 50.w,
                height: 50.w,
                fit: BoxFit.contain,
              ).enshroudAll(10.w),
            ),
            20.h.boxHeight,

            // 标题
            Text('Login Required')
                .applyTypeSize(22.sp)
                .applyTypeColor(RazeConstants.black)
                .applyNotoSans(weight: FontWeight.bold),
            10.h.boxHeight,
            Text('This feature requires login')
                .applyTypeSize(14.sp)
                .applyTypeColor(RazeConstants.black.withOpacity(0.6))
                .applyNotoSans()
                .enshroudHorizontal(24.w),
            32.h.boxHeight,

            // 装饰分隔线
            Container(
              width: 240.w,
              height: 1,
              decoration: BoxDecoration(
                gradient: LinearGradient(
                  colors: [
                    Colors.transparent,
                    RazeConstants.blue.withOpacity(0.3),
                    Colors.transparent,
                  ],
                ),
              ),
            ),
            24.h.boxHeight,

            // 按钮区域
            Row(
              children: [
                // 取消按钮
                Expanded(
                  child: Container(
                        height: 48.h,
                        decoration: BoxDecoration(
                          border: Border.all(
                            color: RazeConstants.black.withOpacity(0.2),
                            width: 1.5,
                          ),
                          borderRadius: BorderRadius.circular(12.r),
                        ),
                        child: Center(
                          child: Text('Cancel')
                              .applyTypeSize(16.sp)
                              .applyTypeColor(
                                RazeConstants.black.withOpacity(0.6),
                              )
                              .applyNotoSans(weight: FontWeight.bold),
                        ),
                      )
                      .enshroudLeft(24.w)
                      .enshroudRight(8.w)
                      .withTouchResonance(
                        onTap: () {
                          Get.back();
                        },
                      ),
                ),

                // 前往登录按钮
                Expanded(
                  child: Container(
                        height: 48.h,
                        decoration: BoxDecoration(
                          color: RazeConstants.blue,
                          borderRadius: BorderRadius.circular(12.r),
                          boxShadow: [
                            BoxShadow(
                              color: RazeConstants.blue.withOpacity(0.3),
                              blurRadius: 8,
                              offset: const Offset(0, 4),
                            ),
                          ],
                        ),
                        child: Center(
                          child: Text('Go to Login')
                              .applyTypeSize(16.sp)
                              .applyTypeColor(RazeConstants.white)
                              .applyNotoSans(weight: FontWeight.bold),
                        ),
                      )
                      .enshroudLeft(8.w)
                      .enshroudRight(24.w)
                      .withTouchResonance(
                        onTap: () {
                          Get.back();
                          Get.toNamed('/login');
                        },
                      ),
                ),
              ],
            ),

            24.h.boxHeight,
          ],
        ),
      ),
    );
  }
}
